package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;

/**
 * 大攻略Model对象
 */
@Getter
@Setter
public class Strategy extends BaseDomain {
    /**
     * 普通
     */
    public static final Integer STATE_COMMON = 1;
    /**
     * 推荐
     */
    public static final Integer STATE_HOT = 2;
    /**
     * 禁用
     */
    public static final Integer STATE_DISABLE = -1;


    /**
     * 攻略地区
     */
    private Region place;
    /**
     * 攻略标题
     */
    private String title;
    /**
     * 攻略副标题
     */
    private String subTitle;
    /**
     * 攻略封面
     */
    private String coverUrl;
    /**
     * 攻略状态
     */
    private Integer state;

    /**
     * 获取状态中文字符串表示
     * @return
     */
    public String getStateName() {

        if (STATE_HOT.equals(state)) {
            return "推荐";
        } else if (STATE_DISABLE.equals(state)) {
            return "禁用";
        } else {
            return "普通";
        }
    }

    public String getJson() {
        HashMap<String, Object> map = new HashMap<>();
        map.put("id", id);
        map.put("title", title);
        map.put("subTitle", subTitle);
        if (place != null) {
            map.put("placeId", place.getId());
        }
        map.put("state", state);
        map.put("coverUrl", coverUrl);
        return JSONUtil.toJSONString(map);
    }
}